﻿#include "MainWindow.h"
#include"TableWindow.h"
#include "FundInfoDockWidget.h"
#include"FindHistoryDockWidget.h"
#include<QDebug>
#include<QDockWidget>
#include<QTableView>
#include<QStandardItemModel>
#include<QButtonGroup>
#include<QPushButton>
#include<QStatusBar>
#include<QToolBar>
#include<QSpinBox>
#include<QHeaderView>
#include<QLabel>
#include<iostream>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    resize(900, 640);
    m_TableWindow = new TableWindow(this);
    setCentralWidget(m_TableWindow);

    DockWidget();
    auto bar = statusBar();
    bar->showMessage("准备就绪");
   
    //auto tool= TableWindow->addToolBar("工具栏");
    //tool->addWidget(new QLabel("100", this));
    //tool->addWidget(m_SpinBox);
    //bar->insertPermanentWidget(0,m_SpinBox);
    //m_SpinBox->resize(100, 40);
    //qInfo() << find.FindFundName();//联网查询全部基金的基本信息(名字-代码-类型)
    //find.WriteFundName("Fund/FundName.csv");
    //qInfo() << "请输入基金代码:";
    //find.whileFundName();//遍历基金详情
    
    //find.FindHistoryAll(1,100);
    ////find.WriteHistory(1, "Fund");
    //find.ReadHistory("Fund/000001.csv");
   // find.whileFundHistory(1);
}

void MainWindow::DockWidget()
{
     m_FundInfoDockWidget = new FundInfoDockWidget(&m_FindFund, this);
    addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea , m_FundInfoDockWidget);
    //m_FundInfoDockWidget->setFixedWidth(200);

    m_FindHistoryDockWidget = new FindHistoryDockWidget(&m_FindFund, this);
    addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, m_FindHistoryDockWidget);
    //m_FindHistoryDockWidget->setFixedWidth(200);

    tabifyDockWidget(m_FundInfoDockWidget, m_FindHistoryDockWidget);
}

TableWindow* MainWindow::tableWindow()
{
    return m_TableWindow;
}


MainWindow::~MainWindow()
{
}
FundInfoDockWidget* MainWindow::FundInfoDock()
{
    return m_FundInfoDockWidget;
}
FindHistoryDockWidget* MainWindow::FindHistoryDock()
{
    return m_FindHistoryDockWidget;
}
void MainWindow::showMessage(const QString& info, const int timeout)
{
    statusBar()->showMessage(info, timeout);
}
